<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="assets/vue.js"></script>
    <style>
        *{
            list-style: none;
            padding: 0;
            margin: 0;

        }
        #note{
            text-align: center;
            margin: 50px auto 10px;
            width: 700px;
            background: rgba(233, 233, 233, .1);
            min-height: 100px;
            box-shadow: 0 0 50px 10px rgba(0, 0, 0, .3);
            padding: 0 15px;
        }
        #note p{
            color:cornflowerblue ;
            font-size: 30px;
            font-weight: bold;
            padding: 10px 0 20px 0;
        }
        .int input{
            font-weight: 600;
            font-style: italic;
            width: 100%;
            height: 30px;
            font-size: 22px;
            border: none;
            border-bottom: 2px solid rgba(0,0,0, .1);
            padding: 5px 0;
            color: rgba(0, 0, 0, .3);
            outline: none;
        }
        .list ul{
            padding-top: 20px;
        }
        .list ul li{
            color: rgba(0, 0, 0, .4);
            font-size: 20px;
            font-weight: 600;
            text-align: left;
            height: 50px;
            line-height: 70px;
            border-bottom: 2px solid rgba(0,0,0, .1);
        }
        .empty{
            color: rgba(0, 0, 0, .4);
            font-size: 18px;
            width: 1050px;
            text-align: right;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div id="app">
        <div id="note">
            <p>Notepad</p>
            <div class="int">
                <input type="text" @keyDown.enter="hike" placeholder="writing Content,please" v-model="MIP">
            </div>
            <div class="list">
                <ul>
                    <li v-for="(item,index) in say" :key="index">{{item}}</li>
                </ul>
            </div>
        </div>
        <p class="empty" @click="empty">claer</p>
    </div>
</body>
<script>
    const vm=new Vue({
        el:'#app',
        data:{
            say:[
                '青涩的果实，能酸吗？',
                '飞跃吧，束缚的河鱼',
                '砍尽前方的树林'
            ],
            MIP:'',
            store:localStorage,
            bon:"1"
        },
        methods:{
            hike(){
                let MIP=this.MIP.trim()
                if(MIP){
                    this.say.unshift(MIP)
                    this.store.setItem(this.bon,MIP)
                    this.bon=+(this.bon)+1+""
                    this.store.setItem('bon',this.bon)
                }
                this.MIP=""
            },
            empty(){
                this.say=[]
                this.store.clear()
            }
        },
        created(){
            let bon=this.store.getItem('bon')
            this.bon = bon ? bon:'1'
            for(let v in this.store){
               if(this.store.hasOwnProperty(v)){
                   if(!isNaN(+(v))){
                        this.say.unshift(this.store.getItem(v))
                   }
               }
            }
            
        },
        
    })
</script>
</html>